#include <math.h>
#include <iostream>

using std::cout;
using std::endl;
using std::ostream;


class Point {
public:
    //explicit关键字的作用是禁止隐式转换
    explicit
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int,int)" << endl;
    }

    void print() const
    {
        cout << "(" << _ix 
             << "," << _iy
             << ")" << endl;
    }

    friend ostream & operator<<(ostream &os, const Point & rhs);
    
private:
    int _ix;
    int _iy;
};

ostream & operator<<(ostream &os, const Point & rhs)
{
    os << "(" << rhs._ix
       << "," << rhs._iy
       << ")";
    return os;
}


int main()
{
    //隐式转换：当该表达式需要正常进行时，编译器会查看
    //Point的构造函数中是否有一个1参数的int版本的构造可以使用
    //如果有就可以偷偷的进行转换；如果没有，就无法编译通过
    //Point = int
    Point pt = 1;//error, 不希望该语句正常编译通过，
                 //就需要在构造函数之前加上explicit
    cout <<"pt:" << pt << endl;

    return 0;
}

